//=======================================================
// 作者：KingSley
// 描述：通过DOTween实现图片移动，并设置动画不受Time.Scale影响
//=======================================================
using UnityEngine;
using System.Collections;
using DG.Tweening;
using UnityEngine.UI;

namespace Babybus.Uno
{
    public class DOTweenWithoutTimeScale : MonoBehaviour
    {
        private void Start()
        {
            DOTween.useSafeMode = true;

            // 让TimeScale = 0
            Time.timeScale = 0;
            Debug.Log("让TimeScale = 0");

            Image image = transform.Find("Image").GetComponent<Image>();
            // 调用DOmove方法来让图片移动
            Tweener tweener = image.rectTransform.DOMove(Vector3.zero, 1f);
            // 设置这个Tween不受Time.scale影响
            tweener.SetUpdate(true);
            // 设置移动类型
            tweener.SetEase(Ease.Linear);
            tweener.onComplete = delegate () {
                Debug.Log("移动完毕事件");
            };
            image.material.DOFade(0, 1f).onComplete = delegate () {
                Debug.Log("褪色完毕事件");
            };
        }
    }
}
